<template>
	<article>
		<el-dialog title="" :visible.sync="bol" :close-on-click-modal="false" :close-on-press-escape="false" :show-close="false" size="tiny">
           <i class="el-icon-close close" @click="cancel" style="color: white;z-index: 99;"></i>
		 <div class="bt">权限设置</div>
			<!-- 默认展开 -->
			<!-- :default-expanded-keys="this.params.row.auth.split(',')" -->

			<el-tree
				:data="dadtaList"
				show-checkbox node-key="name"
  			:default-checked-keys="this.params.row.auth.split(',')"
				ref="tree" class="tree"
				:props="defaultProps">
			</el-tree>

			<span slot="footer" class="dialog-footer">
		    	<el-button @click="cancel">取 消</el-button>
		    	<!-- <el-button  type="primary" @click="setCheckedKeys1">查看权限</el-button> -->
		    	<el-button type="primary" @click="getCheckedKeys">确 定</el-button>
		  	</span>
		</el-dialog>
	</article>
</template>

<script type="text/javascript">
	export default {
		props: ['params'],
		data() {
			return {
				bol: true,
				dadtaList: [
//				{
//						name: 'yf',
//						label: '研发',
//						children: [{
//								name: 'yfjkgl',
//								label: '接口管理',
//								children:[{
//									name:'xzrygledit',
//									label:'修改'
//								},{
//									name:'xzryglclass',
//									label:'查看班级'
//								},{
//									name:'xzryglforbidden',
//									label:'禁用'
//								},{
//									name:'xzryglauthority',
//									label:'权限'
//								},{
//									name:'xzryglreset',
//									label:'密码重置'
//								},{
//									name:'xzryglsingleDelete',
//									label:'删除'
//								},
//							  ]
//							},
//							{
//								name: 'yfjkjk',
//								label: '接口监控',
//								children:[{
//									name:'xzrygledit',
//									label:'修改'
//								},{
//									name:'xzryglclass',
//									label:'查看班级'
//								},{
//									name:'xzryglforbidden',
//									label:'禁用'
//								},{
//									name:'xzryglauthority',
//									label:'权限'
//								},{
//									name:'xzryglreset',
//									label:'密码重置'
//								},{
//									name:'xzryglsingleDelete',
//									label:'删除'
//								},
//							  ]
//							},
//							{
//								name: 'yfsjkbgl',
//								label: '数据库表管理',
//								children:[{
//									name:'xzrygledit',
//									label:'修改'
//								},{
//									name:'xzryglclass',
//									label:'查看班级'
//								},{
//									name:'xzryglforbidden',
//									label:'禁用'
//								},{
//									name:'xzryglauthority',
//									label:'权限'
//								},{
//									name:'xzryglreset',
//									label:'密码重置'
//								},{
//									name:'xzryglsingleDelete',
//									label:'删除'
//								},
//							  ]
//							}
//						]
//					},
					{
						name: 'xz',
						label: '行政',
						children: [{
								name: 'xzrygl',
								label: '人员管理',
								children:[{
									name:'xzrygledit',
									label:'修改'
								},{
									name:'xzryglclass',
									label:'查看班级'
								},{
									name:'xzryglforbidden',
									label:'禁用'
								},{
									name:'xzryglauthority',
									label:'权限'
								},{
									name:'xzryglreset',
									label:'密码重置'
								},{
									name:'xzryglsingleDelete',
									label:'删除'
								},
							  ]
							},
							{
								name: 'xzjsgl',
								label: '教室管理',
								children:[{
									name:'xzjsgledit',
									label:'修改'
								},{
									name:'xzjsglclass',
									label:'查看班级'
								},{
									name:'xzjsglforbidden',
									label:'禁用'
								},{
									name:'xzjsglauthority',
									label:'权限'
								},{
									name:'xzjsglreset',
									label:'密码重置'
								},{
									name:'xzjsglsingleDelete',
									label:'删除'
								},
							  ]
							},
//							{
//								name: 'xzpjgl',
//								label: '评价管理',
//								children:[{
//									name:'xzrygledit',
//									label:'修改'
//								},{
//									name:'xzryglclass',
//									label:'查看班级'
//								},{
//									name:'xzryglforbidden',
//									label:'禁用'
//								},{
//									name:'xzryglauthority',
//									label:'权限'
//								},{
//									name:'xzryglreset',
//									label:'密码重置'
//								},{
//									name:'xzryglsingleDelete',
//									label:'删除'
//								},
//							  ]
//							},
//							{
//								name: 'xzqjgl',
//								label: '请假管理',
//								children:[{
//									name:'xzrygledit',
//									label:'修改'
//								},{
//									name:'xzryglclass',
//									label:'查看班级'
//								},{
//									name:'xzryglforbidden',
//									label:'禁用'
//								},{
//									name:'xzryglauthority',
//									label:'权限'
//								},{
//									name:'xzryglreset',
//									label:'密码重置'
//								},{
//									name:'xzryglsingleDelete',
//									label:'删除'
//								},
//							  ]
//							},
							{
								name: 'xzjjrgl',
								label: '节假日管理',
								children:[{
									name:'xzjjrgledit',
									label:'修改'
								},{
									name:'xzjjrglclass',
									label:'查看班级'
								},{
									name:'xzjjrglforbidden',
									label:'禁用'
								},{
									name:'xzjjrglauthority',
									label:'权限'
								},{
									name:'xzjjrglreset',
									label:'密码重置'
								},{
									name:'xzjjrglsingleDelete',
									label:'删除'
								},
							  ]
							},
							{
								name: 'xzlsjs',
								label: '老师（结算）',
								children:[{
									name:'xzlsjsedit',
									label:'修改'
								},{
									name:'xzlsjsclass',
									label:'查看班级'
								},{
									name:'xzlsjsforbidden',
									label:'禁用'
								},{
									name:'xzlsjsauthority',
									label:'权限'
								},{
									name:'xzlsjsreset',
									label:'密码重置'
								},{
									name:'xzlsjssingleDelete',
									label:'删除'
								},
							  ]
							}
						]
					},
					{
						name: 'jw',
						label: '教务',
						children: [
						    {
								name: 'jwbjgl',
								label: '班级管理',
								children:[{
									name:'jwbjgledit',
									label:'修改'
								},{
									name:'jwbjglclass',
									label:'查看班级'
								},{
									name:'jwbjglforbidden',
									label:'禁用'
								},{
									name:'jwbjglauthority',
									label:'权限'
								},{
									name:'jwbjglreset',
									label:'密码重置'
								},{
									name:'jwbjglsingleDelete',
									label:'删除'
								},
							  ]
							},
							{
								name: 'jwxsgl',
								label: '学生管理',
								children:[{
									name:'jwxsgledit',
									label:'修改'
								},{
									name:'jwxsglclass',
									label:'查看班级'
								},{
									name:'jwxsglforbidden',
									label:'禁用'
								},{
									name:'jwxsglauthority',
									label:'权限'
								},{
									name:'jwxsglreset',
									label:'密码重置'
								},{
									name:'jwxsglsingleDelete',
									label:'删除'
								},
							  ]
							},
							{
								name: 'jwpkgl',
								label: '排课管理',
								children:[{
									name:'jwpkgledit',
									label:'修改'
								},{
									name:'jwpkglclass',
									label:'查看班级'
								},{
									name:'jwpkglforbidden',
									label:'禁用'
								},{
									name:'jwpkglauthority',
									label:'权限'
								},{
									name:'jwpkglreset',
									label:'密码重置'
								},{
									name:'jwpkglsingleDelete',
									label:'删除'
								},
							  ]
							},
							{
								name: 'jwlskb',
								label: '老师课表',
								children:[{
									name:'jwlskbedit',
									label:'修改'
								},{
									name:'jwlskbclass',
									label:'查看班级'
								},{
									name:'jwlskbforbidden',
									label:'禁用'
								},{
									name:'jwlskbauthority',
									label:'权限'
								},{
									name:'jwlskbreset',
									label:'密码重置'
								},{
									name:'jwlskbsingleDelete',
									label:'删除'
								},
							  ]
							},

//							{
//								name: 'jwqxkb',
//								label: '全校课表',
//								children:[{
//									name:'xzrygledit',
//									label:'修改'
//								},{
//									name:'xzryglclass',
//									label:'查看班级'
//								},{
//									name:'xzryglforbidden',
//									label:'禁用'
//								},{
//									name:'xzryglauthority',
//									label:'权限'
//								},{
//									name:'xzryglreset',
//									label:'密码重置'
//								},{
//									name:'xzryglsingleDelete',
//									label:'删除'
//								},
//							  ]
//							},
							{
								name: 'jwkq',
								label: '考勤',
								children:[{
									name:'jwkqedit',
									label:'修改'
								},{
									name:'jwkqclass',
									label:'查看班级'
								},{
									name:'jwkqforbidden',
									label:'禁用'
								},{
									name:'jwkqauthority',
									label:'权限'
								},{
									name:'jwkqreset',
									label:'密码重置'
								},{
									name:'jwkqsingleDelete',
									label:'删除'
								},
							  ]
							},
							{
								name: 'jwkscjgl',
								label: '考试成绩管理',
								children:[{
									name:'jwkscjgledit',
									label:'修改'
								},{
									name:'jwkscjglclass',
									label:'查看班级'
								},{
									name:'jwkscjglforbidden',
									label:'禁用'
								},{
									name:'jwkscjglauthority',
									label:'权限'
								},{
									name:'jwkscjglreset',
									label:'密码重置'
								},{
									name:'jwkscjglsingleDelete',
									label:'删除'
								},
							  ]
							},
							{
								name: 'jwzycjgl',
								label: '作业成绩管理',
								children:[{
									name:'jwzycjgledit',
									label:'修改'
								},{
									name:'jwzycjglclass',
									label:'查看班级'
								},{
									name:'jwzycjglforbidden',
									label:'禁用'
								},{
									name:'jwzycjglauthority',
									label:'权限'
								},{
									name:'jwzycjglreset',
									label:'密码重置'
								},{
									name:'jwzycjglsingleDelete',
									label:'删除'
								},
							  ]
							},
							{
								name: 'jwxxgl',
								label: '消息管理',
								children:[{
									name:'jwxxgledit',
									label:'修改'
								},{
									name:'jwxxglclass',
									label:'查看班级'
								},{
									name:'jwxxglforbidden',
									label:'禁用'
								},{
									name:'jwxxglauthority',
									label:'权限'
								},{
									name:'jwxxglreset',
									label:'密码重置'
								},{
									name:'jwxxglsingleDelete',
									label:'删除'
								},
							  ]
							},
							{
								name: 'jwtsjwjc',
								label: '听说作业检查',
								children:[{
									name:'jwtsjwjcedit',
									label:'修改'
								},{
									name:'jwtsjwjcclass',
									label:'查看班级'
								},{
									name:'jwtsjwjcforbidden',
									label:'禁用'
								},{
									name:'jwtsjwjcauthority',
									label:'权限'
								},{
									name:'jwtsjwjcreset',
									label:'密码重置'
								},{
									name:'jwtsjwjcsingleDelete',
									label:'删除'
								},
							  ]
							},
						]
					},
					{
						name: 'bmjf',
						label: '报名缴费',
						children: [{
								name: 'bmjfjfgl',
								label: '缴费管理',
								children:[{
									name:'bmjfjfgledit',
									label:'修改'
								},{
									name:'bmjfjfglclass',
									label:'查看班级'
								},{
									name:'bmjfjfglforbidden',
									label:'禁用'
								},{
									name:'bmjfjfglauthority',
									label:'权限'
								},{
									name:'bmjfjfglreset',
									label:'密码重置'
								},{
									name:'bmjfjfglsingleDelete',
									label:'删除'
								},
							  ]
							},
							{
								name: 'bmjfjfjl',
								label: '缴费记录',
								children:[{
									name:'bmjfjfjledit',
									label:'修改'
								},{
									name:'bmjfjfjlclass',
									label:'查看班级'
								},{
									name:'bmjfjfjlforbidden',
									label:'禁用'
								},{
									name:'bmjfjfjlauthority',
									label:'权限'
								},{
									name:'bmjfjfjlreset',
									label:'密码重置'
								},{
									name:'bmjfjfjlsingleDelete',
									label:'删除'
								},
							  ]
							},
							{
								name: 'bmjftfgl',
								label: '退费管理',
								children:[{
									name:'bmjftfgledit',
									label:'修改'
								},{
									name:'bmjftfglclass',
									label:'查看班级'
								},{
									name:'bmjftfglforbidden',
									label:'禁用'
								},{
									name:'bmjftfglauthority',
									label:'权限'
								},{
									name:'bmjftfglreset',
									label:'密码重置'
								},{
									name:'bmjftfglsingleDelete',
									label:'删除'
								},
							  ]
							},
							{
								name: 'bmjftfsh',
								label: '退费审核',
								children:[{
									name:'bmjftfshedit',
									label:'修改'
								},{
									name:'bmjftfshclass',
									label:'查看班级'
								},{
									name:'bmjftfshforbidden',
									label:'禁用'
								},{
									name:'bmjftfshauthority',
									label:'权限'
								},{
									name:'bmjftfshreset',
									label:'密码重置'
								},{
									name:'bmjftfshsingleDelete',
									label:'删除'
								},
							  ]
							},
							{
								name: 'bmjftftj',
								label: '退费统计',
								children:[{
									name:'bmjftftjedit',
									label:'修改'
								},{
									name:'bmjftftjclass',
									label:'查看班级'
								},{
									name:'bmjftftjforbidden',
									label:'禁用'
								},{
									name:'bmjftftjauthority',
									label:'权限'
								},{
									name:'bmjftftjreset',
									label:'密码重置'
								},{
									name:'bmjftftjsingleDelete',
									label:'删除'
								},
							  ]
							}
						]
					},
					{
						name: 'jxcgl',
						label: '进销存管理',
						children: [{
								name: 'jxcglckszgl',
								label: '仓库设置管理',
								children:[{
									name:'jxcglckszgledit',
									label:'修改'
								},{
									name:'jxcglckszglclass',
									label:'查看班级'
								},{
									name:'jxcglckszglforbidden',
									label:'禁用'
								},{
									name:'jxcglckszglauthority',
									label:'权限'
								},{
									name:'jxcglckszglreset',
									label:'密码重置'
								},{
									name:'jxcglckszglsingleDelete',
									label:'删除'
								},
							  ]
							},
							{
								name: 'jxcglwpflgl',
								label: '物品分类管理',
								children:[{
									name:'jxcglwpflgledit',
									label:'修改'
								},{
									name:'jxcglwpflglclass',
									label:'查看班级'
								},{
									name:'jxcglwpflglforbidden',
									label:'禁用'
								},{
									name:'jxcglwpflglauthority',
									label:'权限'
								},{
									name:'jxcglwpflglreset',
									label:'密码重置'
								},{
									name:'jxcglwpflglsingleDelete',
									label:'删除'
								},
							  ]
							},
							{
								name: 'jxcglwpgl',
								label: '物品管理',
								children:[{
									name:'jxcglwpgledit',
									label:'修改'
								},{
									name:'jxcglwpglclass',
									label:'查看班级'
								},{
									name:'jxcglwpglforbidden',
									label:'禁用'
								},{
									name:'jxcglwpglauthority',
									label:'权限'
								},{
									name:'jxcglwpglreset',
									label:'密码重置'
								},{
									name:'jxcglwpglsingleDelete',
									label:'删除'
								},
							  ]
							},
							{
								name: 'jxcglcgrk',
								label: '采购入库',
								children:[{
									name:'jxcglcgrkedit',
									label:'修改'
								},{
									name:'jxcglcgrkclass',
									label:'查看班级'
								},{
									name:'jxcglcgrkforbidden',
									label:'禁用'
								},{
									name:'jxcglcgrkauthority',
									label:'权限'
								},{
									name:'jxcglcgrkreset',
									label:'密码重置'
								},{
									name:'jxcglcgrksingleDelete',
									label:'删除'
								},
							  ]
							},
							{
								name: 'jxcglbs',
								label: '报损',
								children:[{
									name:'jxcglbsedit',
									label:'修改'
								},{
									name:'jxcglbsclass',
									label:'查看班级'
								},{
									name:'jxcglbsforbidden',
									label:'禁用'
								},{
									name:'jxcglbsauthority',
									label:'权限'
								},{
									name:'jxcglbsreset',
									label:'密码重置'
								},{
									name:'jxcglbssingleDelete',
									label:'删除'
								},
							  ]
							},
							{
								name: 'jxcgllyytl',
								label: '领用与退领',
								children:[{
									name:'jxcgllyytledit',
									label:'修改'
								},{
									name:'jxcgllyytlclass',
									label:'查看班级'
								},{
									name:'jxcgllyytlforbidden',
									label:'禁用'
								},{
									name:'jxcgllyytlauthority',
									label:'权限'
								},{
									name:'jxcgllyytlreset',
									label:'密码重置'
								},{
									name:'jxcgllyytlsingleDelete',
									label:'删除'
								},
							  ]
							},
							{
								name: 'jxcglpd',
								label: '盘点',
								children:[{
									name:'jxcglpdedit',
									label:'修改'
								},{
									name:'jxcglpdclass',
									label:'查看班级'
								},{
									name:'jxcglpdforbidden',
									label:'禁用'
								},{
									name:'jxcglpdauthority',
									label:'权限'
								},{
									name:'jxcglpdreset',
									label:'密码重置'
								},{
									name:'jxcglpdsingleDelete',
									label:'删除'
								},
							  ]
							},
							{
								name: 'jxcglkssz',
								label: '课时设置',
								children:[{
									name:'jxcglksszedit',
									label:'修改'
								},{
									name:'jxcglksszclass',
									label:'查看班级'
								},{
									name:'jxcglksszforbidden',
									label:'禁用'
								},{
									name:'jxcglksszauthority',
									label:'权限'
								},{
									name:'jxcglksszreset',
									label:'密码重置'
								},{
									name:'jxcglksszsingleDelete',
									label:'删除'
								},
							  ]
							},
							{
								name: 'jxcglkccx',
								label: '库存查询',
								children:[{
									name:'jxcglkccxedit',
									label:'修改'
								},{
									name:'jxcglkccxclass',
									label:'查看班级'
								},{
									name:'jxcglkccxforbidden',
									label:'禁用'
								},{
									name:'jxcglkccxauthority',
									label:'权限'
								},{
									name:'jxcglkccxreset',
									label:'密码重置'
								},{
									name:'jxcglkccxsingleDelete',
									label:'删除'
								},
							  ]
							},

							{
								name: 'jxcglcgth',
								label: '采购退货',
								children:[{
									name:'jxcglcgthedit',
									label:'修改'
								},{
									name:'jxcglcgthclass',
									label:'查看班级'
								},{
									name:'jxcglcgthforbidden',
									label:'禁用'
								},{
									name:'jxcglcgthauthority',
									label:'权限'
								},{
									name:'jxcglcgthreset',
									label:'密码重置'
								},{
									name:'jxcglcgthsingleDelete',
									label:'删除'
								},
							  ]
							},
							{
								name: 'jxcglxsxs',
								label: '学生销售',
								children:[{
									name:'jxcglxsxsedit',
									label:'修改'
								},{
									name:'jxcglxsxsclass',
									label:'查看班级'
								},{
									name:'jxcglxsxsforbidden',
									label:'禁用'
								},{
									name:'jxcglxsxsauthority',
									label:'权限'
								},{
									name:'jxcglxsxsreset',
									label:'密码重置'
								},{
									name:'jxcglxsxssingleDelete',
									label:'删除'
								},
							  ]
							},
						]
					}

				],
				defaultProps: {
					children: 'children',
					label: 'label'
				}
			}
		},
		created () {
			console.log(this.defaultProps)
			console.log(this.params.row.id)
			console.log(this.params.row.auth.split(','))
//			var children = this.params.row.auth.split(',')
//			this.setCheckedKeys(children, false)
			// this.setCheckedKeys1()
		},
		// mounted:function(){
		// 	this.setCheckedKeys1()
		// },
		methods: {
			cancel() {
				this.$emit('close', {
					type: 'authority',
					cancel: true
				})
			},
			// setCheckedKeys1(){
			//
			// 	   this.$refs.tree.setCheckedKeys(this.params.row.auth.split(','));
			// },
			getCheckedKeys() {
//				alert(scope)
				var all=this.$refs.tree.getCheckedKeys();
				console.log(all)
				this.axios.get(this.$store.state.api+'ls/auth',{
					params:{
						id:this.params.row.id,
						auth:all+''
					}
				}).then(res => {
					console.log(res)
				})
				this.$emit('close', {
					type: 'authority',
					cancel: true
				})
				console.log(this.$refs.tree.getCheckedKeys());

			}

		}
	}
</script>
<style lang="less" scoped>
.bt{
			position: absolute;
			width: 100%;
			height: 50px;
			margin: 0 auto;
			top:0;
			left:0;
			background: #50BFFF;
			margin-bottom: 20px;
			color:white;
			text-align:left;
			line-height: 50px;
			font-size: 17px;
			padding-left: 15px;
		}
		.tree{
			margin-top: 20px;
		}
</style>
